package bdqn.t09.controller;

import bdqn.t09.pojo.AsContacts;
import bdqn.t09.pojo.AsCustoms;
import bdqn.t09.pojo.AsKeywords;
import bdqn.t09.service.AsContactsService;
import bdqn.t09.service.AsCustomsService;
import bdqn.t09.service.AsKeywordsService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class AsCustomsController {
    @Resource
    private AsCustomsService asCustomsasService;

    @Resource
    private AsKeywordsService asKey;
    @Resource
    private AsContactsService asContactsService;

    @RequestMapping("/menhuinfo")
    public String menHuInfo(Long id,String caozuo, Model model){
        AsCustoms asCustoms = asCustomsasService.selectByPrimaryKey(id);
        AsKeywords asKeywords = asKey.selectByPrimaryKey(asCustoms.getId());
        AsContacts asContacts = asContactsService.selectByPrimaryKey(asCustoms.getId());
        model.addAttribute("asCustoms",asCustoms);
        model.addAttribute("asKeywords",asKeywords);
        model.addAttribute("asContacts",asContacts);
        if(caozuo.equals("look")){
            return "findPortal";
        }
           return "updatePortal" ;
    }

    @RequestMapping(value = "/menhuupdate",method = RequestMethod.POST)
    @ResponseBody
    public Object menhuupdate(AsKeywords asKeywords,Long id){
        asKeywords.setId(id);
        int i = asKey.updateByPrimaryKeySelective(asKeywords);
        if(i > 0){
            return "true";
        }
        return "false";
    }
}
